<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let promise = new Promise((resolve, reject) => {
            if (true) {
                resolve('promise成功状态')
            } else {
                reject('promise失败')
            }
        })
        /* promise.then((res)=>{
            console.log(res);
        })
        promise.catch(err=>{
            console.log(err);
        }) */
        /* (async()=>{
            let result = await new Promise((resolve,reject)=>{
                if(true){
                    resolve('promise成功状态')
                }else{
                    reject('promise失败')
                }
            })
            console.log(result);
        })() */
        /* 
        .then  .catch是promise对象上的方法
        .then 函数调用传的参数是一个箭头函数，箭头函数中的res接收的是promise成功状态的值
        promise.then这个函数执行的结果是一个promise对象

        async await 将异步微任务变为同步
        await后面跟promise对象
        await函数的返回值是promise的成功状态的值
        
        
        
        */
        let test1 = promise.then(res => {
            console.log(res);
        })
        console.log(test1);

        /*  let obj = {};
        obj.fun = function(){
            console.log('这是个函数');
        }
        obj.fun();
        let TestTFun = obj.fun();
        console.log(TestTFun);
 */
        let obj = {};
        obj.name = 'tom';
        obj['age'] = 19
    </script>
</body>

</html>